#include "AE.h"

void setCollisionWithObject(ISceneNode* a_obj, const c8 * a_objMeshFilePath, ISceneNode* a_obj2, const c8 * a_obj2MeshFilePath)
{
	ISceneNode* obj = a_obj;
	ISceneNode* obj2 = a_obj2;

	IMesh* objMesh = smgr->getMesh(a_objMeshFilePath);
	IMesh* obj2Mesh = smgr->getMesh(a_obj2MeshFilePath);

	scene::IMetaTriangleSelector * meta = smgr->createMetaTriangleSelector();

	// Then create your ITriangleSelectors as normal and for each one
	// add it to the meta selector, which will take a reference to it
	scene::ITriangleSelector * selector = smgr->createTriangleSelector(objMesh, obj);
	scene::ITriangleSelector * selector2 = smgr->createTriangleSelector(obj2Mesh, obj2);//... create with an appropriate method
	meta->addTriangleSelector(selector);
	meta->addTriangleSelector(selector2);
	 // And drop your reference to it, so that the meta selector owns it.
	selector->drop();
	selector2->drop();


	// After adding all the triangle selectors to the meta selector
	// create a collision response animator from that meta selector.
	// Note that the IMetaTriangleSelector is passed to a method that
	// expects an ITriangleSelector.  This is correct; IMetaTriangleSelector
	// is derived from ITriangleSelectors, so it IS an ITriangleSelector.
	scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(meta, obj2, core::vector3df(5,5,5), core::vector3df(0,-1,0));

	obj2->addAnimator(anim);

	meta->drop(); // I'm done with the meta selector now
	
	
	

	/*ISceneNode* obj2 = a_obj2;

	IMesh* objMesh = smgr->getMesh(a_objMeshFilePath);
	IMesh* obj2Mesh = smgr->getMesh(a_obj2MeshFilePath);


	scene::ITriangleSelector* selector = 0;
	
	if (obj)
	{		
		//obj->setPosition(core::vector3df(-1350,-130,-1400));

		selector = smgr->createTriangleSelector(objMesh, obj);
		obj->setTriangleSelector(selector);
	}


	if (selector)
	{
		scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
			selector, obj2, core::vector3df(30,50,30),
			core::vector3df(0,-3,0), 
			core::vector3df(0,50,0));
		selector->drop();
		obj2->addAnimator(anim);
		anim->drop();
	
	}*/



}

